# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Christian Hesse <mail@eworm.de>
# Contributor: Daenyth <Daenyth+Arch [at] gmail [dot] com>
# Contributor: nofxx <x@nofxx.com>

pkgname=iodine
pkgver=0.7.0
pkgrel=6
pkgdesc='Tunnel IPv4 data through a DNS server'
arch=('loong64' 'x86_64')
url='https://code.kryo.se/iodine'
license=('custom:ISC')
depends=('zlib' 'net-tools')
backup=('etc/conf.d/iodined')
source=("https://code.kryo.se/${pkgname}/${pkgname}-${pkgver}.tar.gz"
        'iodined.service'
        'iodined.conf.d')
sha512sums=('49fe4f0cf614d3400cbfdade84eb4f50430f8f92004f663a08acc1514e8ff342443a8c3f855828bbca1864a3fafe419b5256f8a80fc4024b364d4c8c953fc0ec'
            'cf5838994a677afa04c638d64a0c1bb87c085a690d3c7cf845944a85f9f3c7aceb7a56ddef71abc73f03b1c7ceccca279ef7d784e4988d295958be104da4aa48'
            '07c4733b98287672fe98bdb8d666672994aa675d1bbde58d342471e318f1a7b5fc2f66cb8d068a1a4ef5697647608a217eb1949dfbd5b672b4d8982f09e902aa')

prepare() {
  cd $pkgname-$pkgver
  sed -e 's/-lsystemd-daemon/-lsystemd/' -i src/osflags
}

build() {
  cd ${pkgname}-${pkgver}

  make
}

package() {
  cd ${pkgname}-${pkgver}

  make prefix=/usr sbindir=/usr/bin DESTDIR="${pkgdir}" install
  install -d "${pkgdir}/usr/share/licenses/iodine"
  sed -n '/AUTHORS & LICENSE/,$p' README > "${pkgdir}/usr/share/licenses/iodine/LICENSE"

  install -Dm644 "$srcdir/iodined.service" "$pkgdir/usr/lib/systemd/system/iodined.service"
  install -Dm644 "$srcdir/iodined.conf.d" "$pkgdir/etc/conf.d/iodined"
}
